<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="author" content="featon inc.">
    <link rel="stylesheet" href="/static/vendor/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/vendor/bootstrap/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="/static/vendor/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/static/vendor/skin/ftskin.css">
    <title></title>
</head>

<body style="margin-bottom: 60px;">

<div class="ft-subpage-wrapper container-fluid">
    <form id="form1" name="form1" action="#" method="post">
        <div class="row">
            <div class="col-lg-12" id="form_table">
                <table id="" class="form-table-border" cellpadding="0" cellspacing="0" style="width:100%">
                    <tr>
                        <th><span class="f_red">*</span>密码</th>
                        <td>
                            <input id="password" name="password" type="password" class="form-control" value="" placeholder="8-20位数字、字母、特殊符号">
                            <span class="cError"></span>
                        </td>
                    </tr>
                    <tr>
                        <th><span class="f_red">*</span>确认密码</th>
                        <td>
                            <input id="confirm_pw" name="confirm_pw" type="password" class="form-control" value="" placeholder="">
                            <span class="cError"></span>
                        </td>
                    </tr>
                </table>


            </div>
        </div>
    </form>
</div>
<div class="iframe-bottom-tools-box nav navbar-fixed-bottom">
    <button type="button" class="btn btn-info"  id="save_but"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span> 保存</button>
    <button type="button" class="btn btn-warning" onclick="modelWindow.closeFrameWindow();"><span class="glyphicon glyphicon-remove-circle" aria-hidden="true"></span> 取消</button>
</div>
<input type="hidden" th:id="user_id" th:value="${user_id}" />
<script src="/static/vendor/jquery/jquery-3.3.1.min.js"></script>
<script src="/static/vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="/static/vendor/validate/jquery.validate.min.js" type="text/javascript"></script>
<script src="/static/vendor/skin/js/ft-ui.js"></script>
<script src="/static/vendor/skin/js/jquery.c.js"></script>
<script src="/static/vendor/skin/js/java.js"></script>

<script>

    //var user_id = $("#user_id").val();

    jQuery(function($) {
        iniInfoForm();
        $('#save_but').click(addObject)
    });

    $(document).ready(function(){

    });

    function iniInfoForm()
    {
        var validator = $("#form1").validate({
            debug:true,
            rules: {
                password: {
                    required: true,
                    isPassword: true
                },
                confirm_pw: {
                    required: true,
                    equalTo: "#password"
                }
            },
            messages: {
                password: {
                    required: "密码不能为空！",
                    isPassword: "8-20位必须包含含数字、字母、特殊符号"
                },
                confirm_pw: {
                    required: "确认密码不能为空！",
                    equalTo: "两次输入密码不一致"
                }
            },
            errorPlacement: function(error, element) {
                error.appendTo( element.parents('td').find(".cError") );
                // error.appendTo(element.parent());
            },
            submitHandler: function(form) {

            }
        });
    }

    var is_submit = false;
    function addObject()
    {
        if($("#form1").valid())
        {
            if(is_submit == false)
            {
                is_submit = true;
                var con_map = new Map();
                con_map.put("user_id",$("#user_id").val());
                con_map.put("new_pw",$("#password").val());
                if(top.ajax.synclBody("/user/resetPassword",con_map))
                {
                    modelWindow.alert(top.CMSLang.Add_success);
                    modelWindow.closeFrameWindow();
                }else
                {
                    modelWindow.error(top.CMSLang.Add_fail);
                    is_submit = false;
                }
            }
        }
    }

</script>
</body>

</html>
